% Multidimensional Hermite polynomial generating function
%Requires file [Hermite_Polynomials_1D.m]
%========= terms========================== order===== dimensions===== symbols
function nDimTerm=Hermite_Polynomials(order, dimension,x )
cMat=nchoosek(1:(order+dimension),dimension); %Find all combinations
tNum=nchoosek((order+dimension),dimension); %find the number of combinations
nDimTerm =sym(ones(length(cMat(:,1)),1)); %initialize the item matrix
for i=1:tNum
    for j=1:dimension
        oneDimTerm=Hermite_Polynomials_1D(order, [x,num2str(j)]); % all terms of a dimension as one dimension
        if j>1
            inTermNum=cMat(i,j)-cMat(i,j-1); % turn the combination into an index
        else
            inTermNum=cMat(i,j); %same as above
        end
        nDimTerm(i)=nDimTerm(i)*oneDimTerm(inTermNum); % find the multidimensional term
    end
end
end